<?
  require_once '../classes/ConnectionDB.php';
  require_once '../classes/TestDataManager.php';
  require_once '../bean/Tests.php';
  $codice = $_COOKIE['codiceUtente'];
  $connection = ConnectionDB::getInstance()->connectToDB();
  $elencoTest = TestDataManager::getInstance()->getTestSottomessiStudente($connection, $codice);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title></title>
      <style type="text/css">
        #divTests
        {
          font-size: 12px;
          color: yellow;

        }
        td
        {
          text-align: center;
        }

        th
        {
          background-color: blue;

        }
        table
        {
          color: white;
        }

      </style>

      <script type="text/javascript">
        function eseguiTest(key)
        {
          document.getElementById('chiaveTest').value=key;
          document.formEsegui.submit();
        }
      </script>
    </head>
    <body>
      <form method="POST" action="../client/startTest.php" name="formEsegui">
        <input type="hidden" name="chiaveTest" id="chiaveTest"/>
        <input type="hidden" name="codiceStudente" value="<?= $codice ?>" />
      </form>
      <div id="divTests">  
        <center>
          <table width="100%">
            <tr>
              <th>Codice</th>
              <th>Nome</th>
              <th>Tempo a disposizione</th>
              <th>Esegui</th>
            </tr>
          <?
            for ($i = 0; $i < count($elencoTest); $i++)
            {
              $test = TestDataManager::getInstance()->getTestByCodice($connection, $elencoTest[$i]->getCodice());
              $key =  $elencoTest[$i]->getChiaveTest();
          ?>
              <tr>
                <td><?= $elencoTest[$i]->getCodice() ?></td>
                <td><?= $test->getNome() ?></td>
                <td><?= $test->getOre() ?> hh: <?= $test->getMinuti() ?> mm</td>
                <td><input type="button" value="Esegui" onclick="javascript:eseguiTest('<?= $key ?>')"/></td>
              </tr>
          <?
            }
          ?>
        </table>
      </center>
    </div>
  </body>
</html>
